package main

import "fmt"

func foo1(a string, b int) int {
	fmt.Println("a=", a)
	fmt.Println("b=", b)

	c := 100

	return c
}

/*
*
return mul val
*/
func foo2(a string, b int) (int, int) {
	fmt.Println("a=", a)
	fmt.Println("b=", b)

	return 666, 777
}

func foo3(a string, b int) (r1 int, r2 int) {
	fmt.Println("--- foo3 ----")
	fmt.Println("a=", a)
	fmt.Println("b=", b)

	//给有名称多返回值进行赋值
	r1 = 1000
	r2 = 2000

	return
}

func foo4(a string, b int) (r1, r2 int) {

	fmt.Println("--- foo4 ----")
	fmt.Println("a=", a)
	fmt.Println("b=", b)
	/**
	作为形参 存在默认值为0
	*/
	fmt.Println("r1=", r1)
	fmt.Println("r2=", r2)

	//给有名称多返回值进行赋值
	r1 = 1001
	r2 = 2001

	return

}

/*
*
在main方法前执行init
*/
func init() {
	fmt.Println("main init")
}

func main() {
	c := foo1("aaa", 2222)

	fmt.Println("c=", c)

	ret1, ret2 := foo2("haha", 9999)
	fmt.Println("ret1=", ret1, "ret2=", ret2)

	ret1, ret2 = foo3("haha", 9999)
	fmt.Println("ret1=", ret1, "ret2=", ret2)

	ret1, ret2 = foo4("haha", 9999)
	fmt.Println("ret1=", ret1, "ret2=", ret2)
	fmt.Println("test")
}
